//from http://www.xulplanet.com/tutorials/mozsdk/dragwrap.php

var richListObserver={

  onDragStart: function (evt , transferData, action)
  { 
    var which=evt.target.getAttribute("role");
    var idx=-1;
    
    if(which=='thundernote')
    {
      idx=evt.target.getAttribute('value');
    }
    else if(which=='image')
    {
      idx=evt.target.parentNode.getAttribute('value');
    }
    else if(which=='title')
    {
      idx=evt.target.parentNode.getAttribute('value');
    }
    
    if(idx!=-1)
    {
      transferData.data=new TransferData();
      transferData.data.addDataForFlavour("text/unicode",idx);
    }
  }
};


var tabLabelObserver={

  onDrop: function (evt , dropData, session)
  { 
    var tabIdx=evt.target.getAttribute('id');
    var noteIdx=dropData.data;
    var rawTabIdx=tabIdx.substring(4);
    var tblName;
    var tno=findNote(noteIdx);
    var noteContent=tno.title+tno.body;
    noteContent=unescape(noteContent);
    var title=getTitle(noteContent);
    var body=getBody(noteContent);
    
    removeNoteFromListForMove(noteIdx);
    if(tabIdx=='tab_uncat')
      tblName='thundernotelist2';
    else
      tblName='rtlb_'+rawTabIdx;
      
    addThunderNote(title,noteIdx,rawTabIdx,tblName);    
    
    modifyExistingNote(title,body,noteIdx,rawTabIdx,'',true,tno.creationdtg,tno.updatedtg,tno.privatenote);
  },

  onDragOver: function (evt , flavour, session)
  { 
  },

  getSupportedFlavours: function ()
  { 
    var flavours = new FlavourSet(); 
    flavours.appendFlavour("text/unicode"); 
    return flavours; 
  }
};

